
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

/**
 * This Class is a Customer Complaint GUI which extends JFrame Object.
 * @author Tal
 *
 */
public class CustomerCompliantGUI extends JFrame
{
	private JTextField DetailsTextField = null;
	private JButton backButton = null;
	private JButton sendComplaintButton = null;
	private JLabel wrnMessage = null;
	private JPanel contentPane=null;
	
	/**
	 * This is Customer Complaint window Constructor.
	 */
	public CustomerCompliantGUI ()
	{ 
		 //CustomerCompliant panel
		   contentPane=new JPanel();
		   
		   contentPane.setBorder(new TitledBorder(null, "Customer Compliant", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		   
		   contentPane.setLayout(null);
		   contentPane.setOpaque(true);
		   contentPane.add(getDetailsField());
		   contentPane.add(getSendComplaintButton());
		   contentPane.add(getWrnMessage());
		   contentPane.add(geBackButton());      
	         
	         //Frame
		        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		        this.setTitle("Customer Compliant Window");
		        this.setContentPane(contentPane);  
			    this.setLocationRelativeTo(null); //This will center the JFrame in the middle of the screen
		        this.setLocationByPlatform(true);
		        this.setSize(500, 334);
		        this.setVisible( true ); // display frame
	               
	  }
		
	/**
	 * This method initializes Details Text Field	
	 */
	private JTextField getDetailsField() {
		if (DetailsTextField == null) {
			DetailsTextField = new JTextField(300);
			DetailsTextField.setBounds(new Rectangle(50, 50, 400, 130));		
		}
		return DetailsTextField;
	}
	
	/**
	 * This method initializes Send Complaint Button	
	 */
	private JButton getSendComplaintButton() {
		if (sendComplaintButton == null) {
			sendComplaintButton = new JButton();
			sendComplaintButton.setBounds(new Rectangle(75, 220, 129, 35));
			sendComplaintButton.setText("Send Complaint");		
		}
		return sendComplaintButton;
	}
	
	
	/**
	 * This method initializes Back Button	
	 */
	private JButton geBackButton() {
		if (backButton == null) {
			backButton = new JButton();
			backButton.setBounds(new Rectangle(268, 220, 129, 35));
			backButton.setText("Back to main");			
		}
		return backButton;
	}
	
	/**
	 * This method creates warning message if currently is null.
	 * @return JLabel type.
	 */
	private JLabel getWrnMessage() {
		if (wrnMessage == null) {
			wrnMessage = new JLabel("You Must Enter Complaint Deatails!!!!");
			wrnMessage.setForeground(Color.RED);
			wrnMessage.setBounds(133, 25, 198, 14);
			wrnMessage.setVisible(false);
		}
		return wrnMessage;
	}
	
	/**
	 * Public Methods
	 * 
	 */
	
	
	/**
	 * This method adds action listener to send Complaint button.
	 * @param listener
	 */
	public void addSendComplaintActionListener(ActionListener listener){
		sendComplaintButton.addActionListener(listener);
	}
	/**
	 * This method add action listener to back to manu button.
	 * @param listener
	 */
	public void addLoginActionListener(ActionListener listener){
		backButton.addActionListener(listener);
	}
	
	/**
	 * This method return Details TextFiels.
	 * @param String-details	 
	 * */
	
	public String getDetails(){
		return this.DetailsTextField.getText();
	}

}
